package com.lc.mdb;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(activationConfig = {
		@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
		@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/mypubsubtopic") })
public class MyPubSub02Bean implements MessageListener {

	@Override
	public void onMessage(Message msg) {
		TextMessage text = (TextMessage) msg;

		try {
			if (text != null && text.getText() != null)
				System.out.println("第二个Pub/Sub消息:" + text.getText());
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}

}
